
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc
VIM_COUNT=`pacman -Qs vim | wc -l`
if [ $VIM_COUNT -le 0 ]
then
echo y | pacman -Sy vim
fi
sed -i 's/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
if [ ! -f /etc/locale.conf ]
then
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
fi
if [ ! -f /etc/hostname ]
then
echo $new_user > /etc/hostname
fi
cat /etc/hosts | grep -E '127.0.0.1\s+localhost' >/dev/null
if [ $? -eq 1 ]
then
	sed -i '$a127.0.0.1   localhost' /etc/hosts
fi
cat /etc/hosts | grep -E '::1\s+localhost'>/dev/null
if [ $? -eq 1 ]
then
	sed -i '$a::1   localhost' /etc/hosts
fi
cat /etc/hosts | grep -E '127.0.1.1\s+'"${new_user}"'.localdomain\s+'"${new_user}"''>/dev/null
if [ $? -eq 1 ]
then
	sed -i '$a127.0.1.1   '"${new_user}"'.localdomain    '"${new_user}"'' /etc/hosts
fi
systemctl enable NetworkManager
echo "${root_password}
${root_password}
" | passwd
bootctl --path=/boot install
cat /boot/loader/loader.conf | grep -E 'default\s+arch'
if [ $? -eq 1 ]
then
	sed -i '$adefault    arch' /boot/loader/loader.conf
fi
cat /boot/loader/loader.conf | grep -E 'timeout\s+4'
if [ $? -eq 1 ]
then
	sed -i '$atimeout    4' /boot/loader/loader.conf
fi
cat /boot/loader/loader.conf | grep -E 'console-mode\s+max'
if [ $? -eq 1 ]
then
	sed -i '$aconsole-mode    max' /boot/loader/loader.conf
fi
cat /boot/loader/loader.conf | grep -E 'editor\s+no'
if [ $? -eq 1 ]
then
	sed -i '$aeditor    no' /boot/loader/loader.conf
fi
if [ ! -f /boot/loader/entries/arch.conf ]
then
	touch /boot/loader/entries/arch.conf
	echo "#self configuration">/boot/loader/entries/arch.conf
fi
cat /boot/loader/entries/arch.conf | grep -E 'title\s+Arch Linux'
if [ $? -eq 1 ]
then
	sed -i '$atitle    Arch Linux' /boot/loader/entries/arch.conf
fi
cat /boot/loader/entries/arch.conf | grep -E 'linux\s+/vmlinuz-linux'
if [ $? -eq 1 ]
then
	sed -i '$alinux    /vmlinuz-linux' /boot/loader/entries/arch.conf
fi
cat /boot/loader/entries/arch.conf | grep -E 'initrd\s+/initramfs-linux.img'
if [ $? -eq 1 ]
then
	sed -i '$ainitrd    /initramfs-linux.img' /boot/loader/entries/arch.conf
fi
cat /boot/loader/entries/arch.conf | grep -E 'options\s+root=PARTUUID='
if [ $? -eq 1 ]
then

	SDA3_UUID=`blkid -s PARTUUID -o value /dev/sda3`
	sed -i '$aoptions    root=PARTUUID='"${SDA3_UUID}"'  rw' /boot/loader/entries/arch.conf
fi
